#!/bin/sh

sudo apt-get -y install build-essential


# 1.卸载python3.10，安装3.6.5
#sudo apt remove -y --autoremove python3.10
#sudo apt remove -y --autoremove python3

#cd /usr/local
#sudo wget --no-check-certificate https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
#sudo tar -xzvf Python-3.6.5.tgz && cd Python-3.6.5
#sudo ./configure --prefix=/usr/local/python3.6.5 && make && make install
#sudo cp /usr/bin/python /usr/bin/python_bak
#sudo rm /usr/bin/python
#sudo rm /usr/bin/python3
#sudo ln -snf /usr/local/python3.6.5/bin/python3.6 /usr/bin/python3

# 2.安装基础包
apt-get -y install git wget gcc make \
    perl m4 flex bison \
    libxml2-dev libxslt-dev \
    python3-setuptools python3-dev libssl-dev libgmp-dev libmpc-dev python3-pip

# 4.安装基础包
pip3 install pyparsing==2.4.0
pip3 install sortedcontainers==2.1.0
pip3 install --upgrade setuptools && pip3 install --upgrade greenlet
pip3 install PySocks ecdsa zfec gipc pycrypto numpy coincurve

# 5.编译安装GMP
wget --no-check-certificate https://gmplib.org/download/gmp/gmp-5.1.3.tar.bz2
tar -jxvf gmp-5.1.3.tar.bz2 && cd gmp-5.1.3 &&./configure && make && make install && cd ..

# 6.编译安装PBC
wget --no-check-certificate https://crypto.stanford.edu/pbc/files/pbc-0.5.14.tar.gz \
    && tar -zxvf pbc-0.5.14.tar.gz \
    && cd pbc-0.5.14 && ./configure \
    && make && make install && cd ..

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
#LIBRARY_PATH /usr/local/lib
#LD_LIBRARY_PATH /usr/local/lib

# 7.编译安装Charm-Crypto，git下载报错
#git clone -b dev https://github.com/JHUISI/charm.git
#git clone -b dev git@github.com:JHUISI/charm.git
cd charm && bash ./configure.sh && make && make install && cd ..
